import java.util.Scanner;

public class demo05 {
    //深搜矩阵(dfs)
    public static int max=0;
    public static int count=0;
    public static int[] dx={0,1,0,-1};
    public static int[] dy={1,0,-1,0};
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=30;
        int m=60;
        char[][] arr=new char[n][m];
        for (int i = 0; i < n; i++) {
            String str=sc.next();
            arr[i]=str.toCharArray();
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if(arr[i][j]=='1'){
                    arr[i][j]='2';
                    count=1;
                    dfs(arr,i,j);
                    if(count>max){
                        max=count;
                    }
                    arr[i][j]='0';
                }
            }
        }
        System.out.println(max);
    }
    public static void dfs(char[][] arr,int i,int j){
        for (int k = 0; k < 4; k++) {
            int i1=i+dx[k];
            int j1=j+dy[k];
            if((i1>=0)&&(i1<arr.length)&&(j1>=0)&&(j1<arr[i].length)){
                if(arr[i1][j1]=='1') {
                    count++;
                    arr[i1][j1] = '2';
                    dfs(arr, i1, j1);
                    arr[i1][j1] = '0';
                }
            }
        }
    }
}
